package com.company.manage.common.utils;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * Created by HuangYong on 2016/1/22.
 * desc:全局配置类
 */
public class Global {
    private static final String TAG = "Global";

    /**
     * 保存全局属性值
     */
    private static Map<String,String> map = Maps.newHashMap();

    /**
     * 属性文件加载对象
     */
    private static PropertiesLoader propertiesLoader = new PropertiesLoader("app.properties");

    /**
     * 获取配置
     * @param key
     * @return
     */
    public static String getConfig(String key){
        String value = map.get(key);

        if (value==null){
            value = propertiesLoader.getProperty(key);
            map.put(key,value);
        }
        return value;
    }

    /**
     * 获取Admin端根路径
     * @return
     */
    public static String getAdminPath() {return getConfig("adminPath");}

    /**
     * 获取前端根路径
     * @return
     */
    public static String getFrontPath(){return getConfig("frontPath");}

    /**
     * 获取URL后缀
     * @return
     */
    public static String getUrlSuffix(){return getConfig("urlSuffix");}
}